#!/bin/sh



is_internal_dir()
{

   matchLength=`expr match "$1" '.*__internal'`
   if [ $matchLength -eq 0 ] && [ $i != "." ]
   then
      return 1      # not '__internal ' and not '.'
   fi
   return 0
}


if [ $# -lt 1 ]
then
   echo "Usage: ./linux_copy_headers.sh [output path]"
   exit
fi

outputDir=../$1/include
mkdir -p $outputDir

cd ./cppflib

#
# create dirs first
#
for i in $(find . -type d);
do
   is_internal_dir $i
   if [ $? -eq 1 ]
   then
      mkdir -p $outputDir/${i:2}
   fi
done

#
# copy header files
#
for i in $(find . -name "*.h" -type f);
do
   is_internal_dir $i
   if [ $? -eq 1 ]
   then
      cp $i $outputDir/${i:2}
   fi
done

